import type { JobBase, PaginationType, StringOptions } from "@/types"
import { reactive, ref } from "vue"

export default function usePageState() {
  // 响应式数据
  const loading = ref<boolean>(false)
  const selectAll = ref<boolean>(false)

  const selectedJobs = ref<Partial<JobBase>[]>([])

  // 搜索表单
  const searchForm = reactive({
    title: '',
    department: '',
    location: '',
    employmentType: '',
    status: ''
  })

  // 分页配置
  const pagination = reactive<PaginationType>({
    current: 1,
    size: 10,
    total: 0
  })

  // 下拉选项数据
  const departmentOptions = ref<StringOptions[]>([
    { label: '技术部', value: '技术部' },
    { label: '产品部', value: '产品部' },
    { label: '设计部', value: '设计部' },
    { label: '市场部', value: '市场部' },
    { label: '销售部', value: '销售部' }
  ])

  const locationOptions = ref<StringOptions[]>([
    { label: '北京', value: '北京' },
    { label: '上海', value: '上海' },
    { label: '深圳', value: '深圳' },
    { label: '杭州', value: '杭州' },
    { label: '广州', value: '广州' }
  ])

  // 表格数据
  const tableData = ref<JobBase[]>([
    {
      id: 1,
      title: 'Java高级开发工程师',
      department: '技术部',
      location: '北京',
      employmentType: 'full_time',
      seniority: 'senior',
      education: 'bachelor',
      salaryMin: 20000,
      salaryMax: 35000,
      currency: 'CNY',
      status: 'open',
      tags: 'Java,Spring Boot,微服务',
      ownerId: 1,
      ownerName: '张三',
      ownerAvatar: '',
      viewsCount: 156,
      applicationsCount: 23,
      createdAt: '2024-01-15T10:30:00',
      updatedAt: '2024-01-20T14:20:00'
    },
    {
      id: 2,
      title: '前端开发工程师',
      department: '技术部',
      location: '上海',
      employmentType: 'full_time',
      seniority: 'mid',
      education: 'bachelor',
      salaryMin: 15000,
      salaryMax: 25000,
      currency: 'CNY',
      status: 'draft',
      tags: 'Vue,React,TypeScript',
      ownerId: 2,
      ownerName: '李四',
      ownerAvatar: '',
      viewsCount: 89,
      applicationsCount: 12,
      createdAt: '2024-01-16T09:15:00',
      updatedAt: '2024-01-19T16:45:00'
    }
  ])
  return {
    loading,
    selectAll,
    selectedJobs,
    searchForm,
    pagination,
    departmentOptions,
    locationOptions,
    tableData
  }
}
